﻿using Microsoft.AspNetCore.Mvc;
using Nasty.Core.Entity.Flow;
using Nasty.Core.LoadParams;
using Nasty.Core.Registry;
using Nasty.FlowModule.Areas.Flow.Model;
using Nasty.FlowModule.Areas.Flow.Params;
using NetTaste;

namespace Nasty.FlowModule.Flow
{
	public interface IFlowService : IAutofacRegister
	{
        public List<FlowLog> GetFlowLogs(string id);

        public Nasty.Core.Entity.Flow.Flow GetFlow(string id);

        public ResultData<Nasty.Core.Entity.Flow.Flow> SaveFlow(FlowModel model);

		public ResultData<FlowNextInfoModel> GetFlowNextInfo(GetFlowNextInfoParams @params);

        public ResultData<string> AgreeFlowNode(AgreeFlowNodeParams @params);

        public ResultData<string> RejectFlowNode(RejectFlowNodeParams @params);

        public ResultData<string> RevokeFlow(string id);

        public PageData<Nasty.Core.Entity.Flow.Flow> GetFlowPage(GetFlowPageParams @params);

        public ResultData<string> DelegateFlowNode(DelegateFlowNodeParams @params);
    }

	public class FlowService : IFlowService
	{
		public required IFlowRepository FlowRepository { get; set; }

        public ResultData<FlowNextInfoModel> GetFlowNextInfo(GetFlowNextInfoParams @params)
        {
            return FlowRepository.GetFlowNextInfo(@params);
        }

        public ResultData<string> AgreeFlowNode(AgreeFlowNodeParams @params)
        {
            return FlowRepository.AgreeFlowNode(@params);
        }

        public ResultData<string> RejectFlowNode(RejectFlowNodeParams @params)
        {
            return FlowRepository.RejectFlowNode(@params);
        }

        public Nasty.Core.Entity.Flow.Flow GetFlow(string id)
		{
			return FlowRepository.GetFlow(id);
		}
		
		public ResultData<Nasty.Core.Entity.Flow.Flow> SaveFlow(FlowModel model)
		{
			return FlowRepository.SaveFlow(model);
		}

        public ResultData<string> RevokeFlow(string id)
        {
            return FlowRepository.RevokeFlow(id);
        }

        public PageData<Nasty.Core.Entity.Flow.Flow> GetFlowPage(GetFlowPageParams @params)
        {
            return FlowRepository.GetFlowPage(@params);
        }

        public List<FlowLog> GetFlowLogs(string id)
        {
            return FlowRepository.GetFlowLogs(id);
        }

        public ResultData<string> DelegateFlowNode(DelegateFlowNodeParams @params)
        {
            return FlowRepository.DelegateFlowNode(@params);
        }
    }
}
